package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.domain.TestVideo;
import com.ruoyi.domain.vo.TestVideoVo;
import com.ruoyi.service.ITestVideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 考试平台视频Controller
 *
 */
@Api(tags = "视频管理接口")
@RestController
@RequestMapping("/exam/video")
public class TestVideoController extends BaseController
{
    @Autowired
    private ITestVideoService testVideoService;

    /**
     * 查询考试平台视频列表
     */
    @ApiOperation("查询考试平台视频列表")
    @GetMapping("/list")
    public TableDataInfo list(String grade)
    {
        startPage();
        List<TestVideoVo> list = testVideoService.selectTestVideoList(grade);
        return getDataTable(list);
    }

    /**
     * 新增考试平台视频
     */
    @ApiOperation("新增考试平台视频")
    @PostMapping
    public AjaxResult add(@RequestBody TestVideo testVideo)
    {
        return toAjax(testVideoService.insertTestVideo(testVideo));
    }

    /**
     * 修改考试平台视频
     */
    @ApiOperation("修改考试平台视频")
    @PutMapping
    public AjaxResult edit(@RequestBody TestVideo testVideo)
    {
        return toAjax(testVideoService.updateTestVideo(testVideo));
    }

    /**
     * 删除考试平台视频
     */
    @ApiOperation("删除考试平台视频")
    @DeleteMapping("/{videoIds}")
    public AjaxResult remove(@PathVariable Long[] videoIds)
    {
        return toAjax(testVideoService.deleteTestVideoByVideoIds(videoIds));
    }
}
